package org.langqiao.network;

import java.io.IOException;
import java.net.InetAddress;

public class InetAddressTest {

	public static void main(String[] args) throws IOException {
		InetAddress ip = InetAddress.getByName("www.baidu.com");
		System.out.println("oneedu是否可达："+ip.isReachable(2000));
		System.out.println("oneedu的主机地址为："+ip.getHostAddress());
		
		InetAddress local = InetAddress.getByAddress(new byte[]{127,0,0,1});
		System.out.println("本地主机是否可达："+local.isReachable(5000));
		System.out.println("获得本地主机完全限定域名："+local.getCanonicalHostName());
		System.out.println("获得本地主机完全限定域名："+local.getHostAddress());
	}

}
